package fr.louloutes.lolshooter.engine.sprites;

import android.graphics.Rect;
import android.graphics.RectF;

/**
 * Class LolRect: rectangle handling
 * 
 * @author Louloute
 * 
 */
public class LolRect extends RectF
{
	/**
	 * Empty constructor
	 */
	public LolRect()
	{
		super();
	}

	/**
	 * First constructor with initialization
	 * 
	 * @param rect
	 */
	public LolRect( Rect rect )
	{
		super( rect );
	}

	/**
	 * Second constructor with initialization
	 * 
	 * @param rectf
	 */
	public LolRect( RectF rectf )
	{
		super();
		left = ( int ) rectf.left;
		top = ( int ) rectf.top;
		right = ( int ) rectf.right;
		bottom = ( int ) rectf.bottom;

	}

	/**
	 * Third constructor with initialization
	 * 
	 * @param left
	 * @param top
	 * @param right
	 * @param bottom
	 */
	public LolRect( int left, int top, int right, int bottom )
	{
		super( left, top, right, bottom );
	}

	/**
	 * Set center position of current LolRect
	 * 
	 * @param x
	 * @param y
	 */
	public void setCenter( int x, int y )
	{
		int width = ( int ) ( right - left );
		int height = ( int ) ( bottom - top );
		assignBounds( x, y, width, height );
	}

	/**
	 * Assign boundaries to current LolRect
	 * 
	 * @param x
	 * @param y
	 * @param width
	 * @param height
	 */
	private void assignBounds( int x, int y, int width, int height )
	{
		left = x - width / 2;
		top = y - height / 2;
		right = x + ( width + 1 ) / 2;
		bottom = y + ( height + 1 ) / 2;
	}
}
